package com.middlegroup.pay.web.api;

import com.middlegroup.common.model.ResponseEntity;
import com.middlegroup.common.model.TransRequest;
import com.middlegroup.common.model.TransResult;
import com.middlegroup.pay.bind.SessionMerchantCode;
import com.middlegroup.pay.bind.SessionSubjectCode;
import com.middlegroup.pay.service.SubjectPayService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 *快捷支付
 * @author pc
 * @date 2019/1/15
 */
@RestController
public class QuickPayController extends BaseController {

    @Resource
    private SubjectPayService subjectPayService;

    /**快捷支付
     * @param request
     * @param merchantCode
     * @param subjectCode
     * @return
     */
    @RequestMapping("quickPay")
    public ResponseEntity quickPay(@Valid TransRequest request, @SessionMerchantCode String merchantCode, @SessionSubjectCode String subjectCode){
        request.setMerchantCode(merchantCode);
        request.setSubjectCode(subjectCode);
        TransResult transResult = subjectPayService.quickPay(request);
        return new ResponseEntity(ResponseEntity.STATUS_OK,transResult);
    }
}
